package SeleniumTest.pages.pages.webdriver;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

import java.io.File;

/**
 * Created with IntelliJ IDEA.
 * User: C13T
 * Date: 10.07.13
 * Time: 19:23
 * To change this template use File | Settings | File Templates.
 */
public class WebDriverFactory {
    public static WebDriver driver;

    public static WebDriver createDriver(String browserName)
    {
        if (browserName.equals("firefox"))
        {
            driver = new FirefoxDriver();
        }
        else if (browserName.equals("chrome"))
        {
            File file = new File("C:\\WebDrivers\\chromedriver.exe");
            System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
            driver = new ChromeDriver();
        }
        else if (browserName.equals("ie"))
        {
            File file = new File("C:\\WebDrivers\\internetexplorerdriver.exe");
            System.setProperty("webdriver.internetexplorer.driver", file.getAbsolutePath());
            driver = new InternetExplorerDriver();
        }
        return driver;
    }

}
